
<h1>Listing events</h1><br />
	</body>
<% if logged_in? %>
	<% a =current_user.id %>
	<% if (current_user.login == "admin")%>
		<table>
		  <tr>
			<th>Name</th>
			<th>Photo image</th>
			<th>Description</th>
			<th>Rating</th>
			<th>Rated</th>
			<th>Good rating</th>
			<th>Bad rating</th>
		  </tr><br />

		<% @events.each do |event| %>
		  <tr>
			<td><%=h event.name %></td>
			<td><%=h event.photo_image %></td>
			<td><%=h event.description %></td>
			<td><%=h event.rating %></td>
			<td><%=h event.rated %></td>
			<td><%=h event.good_rating %></td>
			<td><%=h event.bad_rating %></td>
			<td><%= link_to 'Show', event %></td>
			<td><%= link_to 'Edit', edit_event_path(event) %></td>
			<td><%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => :delete %></td>
			<td><%= link_to 'Location',locations_path%></td>
			
			
					
		  </tr>
		<% end %>
		 </table>

		<br />

	<%= link_to 'Crea tu propio evento', new_event_path %> | | <%= link_to 'Regresar', root_path %>
	<% else %>
	<h3>Mis eventos </h3><br />
		<table>
		  <tr>
			<th>Name</th>
			<th>Photo image</th>
			<th>Description</th>
			<th>Rating</th>
			<th>Rated</th>
			<th>Good rating</th>
			<th>Bad rating</th>
		  </tr>

		<% Event.find(:all, :conditions => ['users_id=?',a]).each do |event| %>
		  <tr>
			<td><%=h event.name %></td>
			<td><% if event.avatar.exists? then %>
					<%= image_tag event.avatar.url(:small) %>
				<% else %>
				<%=h 'No photo' %>
				<%end%></td>
			<td><%=h event.description %></td>
			<td><%=h event.rating %></td>
			<td><%=h event.rated %></td>
			<td><%=h event.good_rating %></td>
			<td><%=h event.bad_rating %></td>
			<td><%= link_to 'Show', event %></td>
			<td><%= link_to 'Edit', edit_event_path(event) %></td>
			<td><%= link_to 'Location',locations_path%></td>
			<td><%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => :delete %></td>
			<td><a href="/comentas/new?eid=<%= event.id %>">Comentar este evento</a></td>
		  </tr>
		<% end %>
		 </table><br />


	<h3>Eventos de otras personas</h3><br />
			<table>
		  <tr>
			<th>Name</th>
			<th>Photo image</th>
			<th>Description</th>
			<th>Rating</th>
			<th>Rated</th>
			<th>Good rating</th>
			<th>Bad rating</th>
		  </tr>

	<% Event.find(:all, :conditions => ['users_id!=?',a]).each do |event| %>
		  <tr>
			<td><%=h event.name %></td>
			<td><% if event.avatar.exists? then %>
					<%= image_tag event.avatar.url(:small) %>
				<% else %>
				<%=h 'No photo' %>
				<%end%>
			</td>
			<td><%=h event.description %></td>
			<td><%=h event.rating %></td>
			<td><%=h event.rated %></td>
			<td><%=h event.good_rating %></td>
			<td><%=h event.bad_rating %></td>
			<td><%= link_to 'Show', event %></td>
			<td><%= link_to 'Location',locations_path%></td>
			<td><%= link_to 'Comment',comentas_path%></td>
		  </tr>
		<% end %>
		 </table><br />

		<br />

	<%= link_to 'Crea tu propio evento', new_event_path %> | <%= link_to 'Regresar', root_path %>

	<% end %>
<% else %>
	<h2>No has iniciado sesi&oacute;n!</h2>
	<p><%= link_to 'Reg&iacute;strate', signup_path%> or <%= link_to 'Inicia sesi&oacute;n', login_path%></p>
<% end %>
